import cv2
cap = cv2.VideoCapture(0)  # 0表示默认的摄像头
cap.set(cv2.CAP_PROP_FRAME_WIDTH,640)
if not cap.isOpened():
    print("无法打开摄像头")
    exit()
while True:
    ret, frame = cap.read()
    if not ret:
        print("无法接收帧")
        break
    cv2.imshow('shexiangtou', frame)
    if cv2.waitKey(1) == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()